{% extends 'users/user-base.html' %}

{% load static %}
{% block title %}添加域{% endblock %}
{% block custom_css %}
    {#    <link href="css/domain.css" rel="stylesheet" title="" type="text/css"/>#}
{% endblock %}

{% block custom_js %}
    <script>
        function check_form(){
        var message = "";
        if($("#exampleInputDomain").val() == ""){
            message = "域名不能为空";
        }else if($("#exampleInputLocation").val() == ""){
            message = "域位置不能为空";
        }else if($("#exampleInputGw-ip").val() == ""){
            message = "网关IP不能为空";
        }else if($("#exampleInputPort").val() == ""){
            message = "端口不能为空";
        }else if($("#exampleInputUser").val() == ""){
            message = "用户名不能为空";
        }else if($("#exampleInputPassword").val() == ""){
            message = "密码不能为空";
        }else if($("#home").val() == ""){
            message = "用户主目录不能为空";
        }else if($("#exampleInputVt_type").val() == ""){
            message = "虚拟化不能为空";
        }
        if(message != ""){
            $("#tipbody").text(message);
            $("#tipModal").modal("show");
            return ;
        }
        $("#domainForm").submit();
    }
    </script>
{% endblock %}

{% block contentVMport %}

        <div class="dashboard-wrapper">
            <div class="dashboard-ecommerce">
                <div class="container-fluid dashboard-content ">
                    <!-- ============================================================== -->
                    <!-- pageheader  -->
                    <!-- ============================================================== -->
                    <div class="row">
                        <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">
                            <div class="page-header">
                                <h2 class="pageheader-title">添加域</h2>
                                <div class="page-breadcrumb">
                                    <nav aria-label="breadcrumb">
                                        <ol class="breadcrumb">
                                            <li class="breadcrumb-item">域管理</a></li>
                                            <li class="breadcrumb-item active" aria-current="page">添加域</li>
                                        </ol>
                                    </nav>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- ============================================================== -->
                    <!-- end pageheader  -->
                    <!-- ============================================================== -->

                    <div class="row">
                        <!-- ============================================================== -->
                        <!-- basic table  -->
                        <!-- ============================================================== -->
                        <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">
                            <div class="card" style="background-color:#FFFFFF">
                                <div class="card-body">
                                    <form id="domainForm" method="post" action="/admins/add_domain/">
                                            <div class="form-group row" style="padding-top:50px">
                                                <label for="exampleInputDomain"
                                                       class="ccol-12 col-sm-3 col-form-label text-right">域名</label>
                                                <div class="col-12 col-sm-8 col-lg-6">
                                                    <input type="text" class="form-control" name="exampleInputDomain"
                                                           id="exampleInputDomain"
                                                           placeholder="域名">
                                                </div>
                                            </div>
                                            <div class="form-group row">
                                                <label for="exampleInputLocation"
                                                       class="ccol-12 col-sm-3 col-form-label text-right">域位置</label>
                                                <div class="col-12 col-sm-8 col-lg-6">
                                                    <input type="text" class="form-control" name="exampleInputLocation"
                                                           id="exampleInputLocation"
                                                           placeholder="域位置">
                                                </div>
                                            </div>
                                            <div class="form-group row">
                                                <label for="exampleInputGw-ip"
                                                       class="ccol-12 col-sm-3 col-form-label text-right">网关IP</label>
                                                <div class="col-12 col-sm-8 col-lg-6">
                                                    <input type="text" class="form-control" name="exampleInputGw-ip"
                                                           id="exampleInputGw-ip"
                                                           placeholder="网关IP">
                                                </div>
                                            </div>
                                            <div class="form-group row">
                                                <label for="exampleInputPort"
                                                       class="ccol-12 col-sm-3 col-form-label text-right">端口</label>
                                                <div class="col-12 col-sm-8 col-lg-6">
                                                    <input type="text" class="form-control" name="exampleInputPort"
                                                           id="exampleInputPort"
                                                           placeholder="22">
                                                </div>
                                            </div>
                                            <div class="form-group row">
                                                <label for="exampleInputUser"
                                                       class="ccol-12 col-sm-3 col-form-label text-right">用户名</label>
                                                <div class="col-12 col-sm-8 col-lg-6">
                                                    <input type="text" class="form-control" name
                                                            ="exampleInputUser" id="exampleInputUser"
                                                           placeholder="">
                                                </div>
                                            </div>
                                            <div class="form-group row">
                                                <label for="exampleInputPassword"
                                                       class="ccol-12 col-sm-3 col-form-label text-right">密码</label>
                                                <div class="col-12 col-sm-8 col-lg-6">
                                                    <input type="text" class="form-control" name="exampleInputPassword"
                                                           id="exampleInputPassword"
                                                           placeholder="">
                                                </div>
                                            </div>
                                            <div class="form-group row">
                                                <label for="exampleInputHomeDir"
                                                       class="ccol-12 col-sm-3 col-form-label text-right">用户主目录</label>
                                                <div class="col-12 col-sm-8 col-lg-6">
                                                    <input type="text" class="form-control" name="home"
                                                           id="home"
                                                           placeholder="">
                                                </div>
                                            </div>
                                            <div class="form-group row">
                                                <label for="exampleInputVt_type"
                                                       class="ccol-12 col-sm-3 col-form-label text-right">虚拟化</label>
                                                <div class="col-12 col-sm-8 col-lg-6">
                                                    <input type="text" class="form-control" name="exampleInputVt_type"
                                                           id="exampleInputVt_type"
                                                           placeholder="KVM/XEN">
                                                </div>
                                            </div>
                                            <div class="form-group row">
                                                <label for="exampleInputBelong"
                                                       class="col-12 col-sm-3 col-form-label text-right">所在服务器</label>
                                                <div class="col-12 col-sm-8 col-lg-6">
                                                    <select name="server" id="server">
                                                        {% for server  in communication_list %}
                                                            <option value="{{ server }}">{{ server }}</option>
                                                        {% endfor %}
                                                    </select>
                                                </div>
                                            </div>
                                            <div class="form-group row text-right">
                                                <div class="col col-sm-10 col-lg-9 offset-sm-1 offset-lg-0">
                                                    <button type="button" class="btn btn-space btn-primary" onclick="check_form()">确认</button>
                                                </div>
                                            </div>
                                            <p class="text-danger text-center">{{ message }}</p>
                                        </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
{% endblock %}